// pages/binding/binding.js

const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        bindengDatas: [
            // {
            //     IdentityNo:"411403200205091036",
            //     FullName:"贾启文",
            //     Tel:"18236363209",
            //     Relationship:"本人"
            // },{
            //     IdentityNo:"474764454354353453",
            //     FullName:"张三",
            //     Tel:"13148071316",
            //     Relationship:"其它"
            // }
        ],
        identityNo: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        if (wx.getStorageSync('identityno')) {
            this.setData({
                identityNo: wx.getStorageSync('identityno')
            })
        }
        wx.request({
            url: app.globalData.baseURL + '/Wechat/Api/GetArchiveList',
            data: {
                username: wx.getStorageSync('userName')
            },
            // data:this.options,
            method: "GET",
            header: {
                'content-type': 'application/json', // 默认值
                "Authorization": wx.getStorageSync('Authorization')
            },
            success: ((res) => {
                console.log(res);
                if (res.data.code == 200) {
                    //    this.data.bindengDatas=res.data.data
                    this.setData({
                        bindengDatas: res.data.data
                    })
                }
                if (res.data.code == 401) {
                    wx.navigateTo({
                        url: "../index/index"
                    })
                }
            })
        })
    },

    relieve(event) {
        console.log(event.currentTarget.dataset.identityno);
        wx.showModal({
            title: app.globalData.isZh ? '提示' : 'Wraning',
            content: app.globalData.isZh ? '是否确认解除该体检人？' : "Are you sure?",
            confirmText: app.globalData.isZh ? '确认' : "Yes",
            cancelText: app.globalData.isZh ? '取消' : "No",
            success(res) {
                if (res.confirm) {
                    wx.request({
                        url: app.globalData.baseURL + '/Wechat/Api/UnLinkArchive',
                        data: {
                            identityNo: event.currentTarget.dataset.identityno,
                            username: wx.getStorageSync('userName')
                        },
                        // data:this.options,
                        method: "POST",
                        header: {
                            'content-type': 'application/json', // 默认值
                            "Authorization": wx.getStorageSync('Authorization')
                        },
                        success: ((res) => {
                            console.log(res);
                        })
                    })
                }
            }
        });
    },
    redirect(e) {
        console.log(e.currentTarget.dataset.identityno);
        wx.setStorageSync('identityno', e.currentTarget.dataset.identityno)
        wx.switchTab({
            url: '../switchpage/switchpage'
        })
    },
    addFun() {
        wx.navigateTo({
            url: "../addbinding/addbinding"
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})